package net.jiupinshi.util;

import com.alibaba.fastjson.JSON;
import net.jiupinshi.common.StaticProperty;
import net.jiupinshi.dto.UserDTO;
import net.jiupinshi.entity.User;

import javax.servlet.http.HttpServletRequest;

/**
 * @Despription: 需要修改
 * @Author: penghui.guo
 * @Date: 2018/10/5 16:48
 */
public class SessionUtil {

    public static UserDTO getUser(HttpServletRequest request){
        return JSON.parseObject(request.getSession().getAttribute(StaticProperty.SESSION_KEY).toString(), UserDTO.class);
    }

    public static Long getUserId(HttpServletRequest request){
        return getUser(request).getId();
    }
}
